<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ include file="../common/tags.jsp"%>   
<%String path = request.getContextPath();%>
<script type="text/javascript">
function submitProductListForm(form){
	if('${searchType}'=='')
		return navTabSearch(form);
	else
	    return dwzSearch(form, 'dialog');
}
</script>
<form id="pagerForm" method="post" action="<%=path %>/product/listProduct.action">
	<input type="hidden" name="pageRequest" value="1" />
	<input type="hidden" name="pageNum" value="${paginator.pageIndex}" />
	<input type="hidden" name="numPerPage" value="${paginator.pageSize}" />
</form>

<div class="pageHeader">
	<form onsubmit="return submitProductListForm(this);" rel="pagerForm" action="<%=path%>/product/listProduct.action" method="post">
	<input type="hidden" name="searchType" value="${searchType}"/>
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">商品编码：</label>
				<input type="text" name="productVO.code" value='<s:property value="productVO.code" />' size="20"/>
			</li>
			<li>
				<label style="text-align: right;">商品名称：</label>
				<input type="text" name="productVO.name" value='<s:property value="productVO.name" />' size="20"/>
			</li>
			<c:choose>
				<c:when test="${SESSION_USER.customer==null}">
					<input name="productVO.customerId" value="<s:property value="productVO.customerId" />" type="hidden">
					<c:if test="${searchType==null||searchType==''}">
						<li>
							<label style="text-align: right;">所属商家：</label>
							<input name="productVO.customerName" onclick="$('#productList_a_btnLook').trigger('click');" style="cursor: pointer;float: left;" value="<s:property value="productVO.customerName" />">
							<!-- <a class="btnLook" id="productList_a_btnLook" href="<%=path %>/customer/listCustomer.action?searchType=active" lookupGroup="productVO">选择</a> -->
						</li>
					</c:if>
				</c:when>
				<c:otherwise>
					<input name="productVO.customerId" value="${SESSION_USER.customer.id}" type="hidden">
				</c:otherwise>
			</c:choose>
		</ul>
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<c:if test="${searchType==null || searchType==''}">
	<div class="panelBar">
		<ul class="toolBar">
			<shiro:hasPermission name="addProduct">
			<li><a class="add" href="<%=path %>/product/addProduct.action" target="navTab"><span>添加</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="deleteProduct">
			<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" postType="string" href="<%=path %>/product/deleteProduct.action" class="delete"><span>删除</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="editProduct">
			<li><a class="edit" href="<%=path %>/product/editProduct.action?productVO.id={sid_user}" target="navTab" warn="请选择一条记录"><span>修改</span></a></li>
			</shiro:hasPermission>
		</ul>
	</div>
	</c:if>
	<table class="table" width="100%" layoutH="139">
		<thead>
			<tr>
				<th width="30"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				<th>商品编码</th>
				<th>商品名称</th>
				<th>商品价格</th>
				<th>商品积分</th>
				<th>所属商家</th>
				<th>所属分类</th>
				<th width="70">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="productList" id="product" status="st">
				<tr target="sid_user" rel="<s:property value="id" />">
					<td><input name="ids" value="<s:property value="id" />" type="checkbox"></td>
             <td><s:property value="code" /></td>	
             <td><s:property value="name" /></td>	
             <td><s:property value="price" /></td>
             <td><s:property value="point" /></td>
             <td><s:property value="customerVO.name" /></td>
             <td><s:property value="ProductKindVO.name" /></td>
					<td>
						<c:if test="${searchType==null || searchType==''}">
							<shiro:hasPermission name="deleteProduct">
							<a title="确实要删除这条记录吗?" target="ajaxTodo" href="<%=path %>/product/deleteProduct.action?ids=<s:property value="id" />" class="btnDel">删除</a>
							</shiro:hasPermission>
							<shiro:hasPermission name="editProduct">
							<a title="编辑" target="navTab" href="<%=path %>/product/editProduct.action?productVO.id=<s:property value="id" />" class="btnEdit">编辑</a>
							</shiro:hasPermission>
						</c:if>
						<c:if test="${searchType == 'lookup'}">
							<a class="btnSelect" href="javascript:$.bringBack({productId:'${id}', productName:'${name}',money:'${price}',score:'${point}'})" title="查找带回">选择</a>
						</c:if>
					</td>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" onchange='<s:if test="%{searchType==null||searchType==''}">navTabPageBreak({numPerPage:this.value})</s:if><s:else>dialogPageBreak({numPerPage:this.value})</s:else>'>
					<option value="15" <c:if test="${paginator.pageSize==15}">selected='selected'</c:if> >15</option>
					<option value="30" <c:if test="${paginator.pageSize==30}">selected='selected'</c:if> >30</option>
					<option value="50" <c:if test="${paginator.pageSize==50}">selected='selected'</c:if> >50</option>
					<option value="100" <c:if test="${paginator.pageSize==100}">selected='selected'</c:if> >100</option>
					<option value="200" <c:if test="${paginator.pageSize==200}">selected='selected'</c:if> >200</option>
				</select>
				<span>条，共${paginator.totalCount}条</span>
			</div>
			<div class="pagination" targetType="${(searchType==null||searchType=='')?'navTab':'dialog'}" totalCount="${paginator.totalCount}" 
				numPerPage="${paginator.pageSize}" pageNumShown="10" currentPage="${paginator.pageIndex}"></div>
	</div>
</div>